set matsize 10000

use panel, clear

// muslim indicators and interactions
gen muslim=(parentalg==1|parenttun==1|parentmor==1|parenttur==1)  					
drop if nat28pr==14|nat28pr==60|nat28pr==61 		
gen y04=(surveyr>=2004)																
drop if surveyr>=2013
gen inter=muslim*y04

tab surveyr, gen(yr_)
sum surveyr, det
local max=r(max)-r(min)+1
disp `max'
forval y=1/`max' {
	gen inter_`y'=yr_`y'*muslim
}

// difference in student status
gen student=(acteu6==5)
replace student=. if acteu6==.
gen diffstud=student-L2.student
la var diffstud "Student status, difference from previous qtr"
gen Lforniv=L2.forniv
gen Lstudent=L2.student
keep if trim=="4"

gen temp1=(Lforniv<=6&surveyr<2008)		// forniv=6 is tertiary from 2008 onwards
gen temp2=(Lforniv<6&surveyr>=2008)

// Men
estimates clear
local sample if ag>16&Lforniv>2&(temp1==1|temp2==1)&Lforniv!=.&Lstudent==1&lnais==1&child==1&female==0
local cl nat28pr
local depvar diffstud
reg `depvar' i.nat28pr inter i.surveyr `sample', cl(`cl')
eststo m1

reg `depvar' i.nat28pr inter i.surveyr i.ag `sample', cl(`cl')
eststo m2

reg `depvar' i.nat28pr inter i.surveyr i.ag i.birthyear `sample', cl(`cl')
eststo m3

reg `depvar' i.nat28pr##i.ag inter i.surveyr i.birthyear `sample', cl(`cl')
eststo m4

reg `depvar' i.nat28pr##i.ag inter i.surveyr i.birthyear `sample'&surveyr<2005, cl(`cl')
eststo m5

esttab m* using "TableA5.csv", star(+ 0.1 * 0.05 ** 0.01 *** 0.001) replace ///
		cells(b(fmt(a3) star) se(par)) stats(N r2)  ///
		keep(inter) 
